package com.hup.vd.view;

import com.hup.utils.commons.start.AppIcon;
import com.hup.utils.commons.start.BaseAppTray;
import com.hup.utils.commons.start.SimpleExitHandler;
import com.hup.utils.commons.start.SpringContext;
import com.hup.utils.commons.start.StartupInfo;
import com.hup.utils.swing.frame.SingletonWindowHelper;

/**
 * @author hugan
 * @date 2021/9/14
 */
public class AppTray extends BaseAppTray {

    public AppTray() {
        super(SpringContext.getBean(AppIcon.class).getImage(), StartupInfo.getApplicationChName());
        setPopupMenu(new SimpleMenu().addExit(), null);
        setTrayListener(new TrayActionListener() {
            @Override
            public void onClickTray() {
                MainFrame window = SingletonWindowHelper.getWindow(MainFrame.class);
                window.setVisible(!window.isVisible());
            }

            @Override
            public void onExit(BaseAppTray appTray) {
                SpringContext.getBean(SimpleExitHandler.class).doExit();
            }
        });
    }

}
